using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using ALib;
using ALib.Data.CSVOperation;

namespace TradingPlatform
{
    public class ExchangeRate
    {
        private readonly SortedList<string, double> _exchangeRateList;
        public ExchangeRate()
        {
            _exchangeRateList = new SortedList<string, double>();

            List<string[]> records = File.Exists(@"Configuration\ExchangeRate.csv") ? CSVEditor.Open(@"Configuration\ExchangeRate.csv", "//") : new List<string[]>();
            foreach (string[] record in records)
            {
                string currency = record[0];
                double rate = double.Parse(record[1]);
                _exchangeRateList.Add(currency,rate);
            }
        }

        public double GetExchangeRateXxxUsd(string currency)
        {
            GoodValue.Assert(_exchangeRateList.ContainsKey(currency));
            double result = _exchangeRateList[currency];
            return result;
        }
    }
}
